from collections import deque

# q=deque()
# N=int(input())
#
# for _ in range(N):
#     op=list(map(int,input().split()))
#     # 入队列
#     if op[0]==0:
#         q.append(op[1])
#     elif op[0]==1:
#         if len(q)==0:
#             print("no")
#         else:
#             print(q.popleft())
#     else:
#         print(len(q))



# 查字典
q = deque()
N, M = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
for x in range(N):
    if x in q:
        continue
    else:
        ans += 1
        q.append(x)
        if len(q) > M:
            q.popleft()
print(ans)
